import api from './api.js';

const loginAsync = async (username, password) => {
  try {
    const result = await api.post({
      command: 'I_Login',
      data: {
        username,
        password,
        category: 0,
        terminal: 0
      }
    }, '/login');

    sessionStorage.token = result.token;
    sessionStorage.userinfo = JSON.stringify(result.data);
  } catch (error) {
    throw error;
  }
};

export default {
  loginAsync,
}